var vm = new Vue({
  el: "#app",
  data: {
    keyword: '',
    isLoading: false,
    list: [],
  },
  beforeMount: function () { },
  mounted() {
    const that = this;
    document.onkeydown = function (event) {
      var e = event || window.event || arguments.callee.caller.arguments[0];
      if (e && e.keyCode == 13) {
        window.location.href = "https://www.baidu.com/s?wd=" + that.keyword;
      }
    };
    this.loadList();
  },
  methods: {
    loadList() {
      const that = this;
      that.isLoading = true;
      fetch("data.json")
        .then(function (response) {
          return response.json();
        })
        .then(function (data) {
          that.list = data;
          that.isLoading = false;
        })
        .catch(function (error) {
          let e = error.message || error;
          console.log(error);
          alert("加载失败" + e);
          that.isLoading = false;
        });
    }
  },
});
